﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MeetSomeNearbyStrangerWebApi.Models;
using MeetSomeNearbyStranger.DataModels;

namespace MeetSomeNearbyStrangerWebApi.Mappers
{
    public class MeatsMapper
    {
        public static MeetModel ToMeatModel(Meet entity, string nickname)
        {
            string otherNickname = "";
            int otherId;
            bool isReceived = false;
            if (nickname == entity.Initiator.Nickname)
            {
                otherNickname = entity.Target.Nickname;
                otherId = entity.Target.Id;
            }
            else
            {
                otherNickname = entity.Initiator.Nickname;
                otherId = entity.Initiator.Id;
                isReceived = true;
            }

            return new MeetModel()
            {
                OtherUserId = otherId, 
                Id = entity.Id,
                IsAccepted = entity.Accepted,
                IsDeclined = entity.Declined,
                Nickname = otherNickname,
                IsReceived = isReceived
            };
        }
    }
}